package com.gamefx.fte
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.InteractiveObject;
	
	public class GraphicDict implements IGraphicDict
	{
		private static var instance:GraphicDict;
		
		public static function getInstance():GraphicDict
		{
			if (instance == null)
				instance = new GraphicDict();
			return instance;
		}
		
		/**
		 * DisplayObject's dictionary
		 * {className, width, height}
		 */ 
		public var dict:Object;
		
		public function GraphicDict()
		{
			dict = {};
		}
		
		public function hasItem(key:String):Boolean
		{
			return dict.hasOwnProperty(key) && (dict[key].hasOwnProperty("className"));
		}
		
		public function getItem(key:String):DisplayObject
		{
			var obj:DisplayObject = new (dict[key].className(key) as Class)();
			if (obj is InteractiveObject)
				InteractiveObject(obj).mouseEnabled = false;
			if (obj is DisplayObjectContainer)
				DisplayObjectContainer(obj).mouseChildren = false;
			return obj;
		}
	}
}